home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / pdselect / awnp / awnp-docs / aexample.doc < prev    next >
Text File  |  2000-02-16  |  3KB  |  57 lines

  1. You should read the simple examples before trying these more advanced ones.
  2.  
  3. HINT: use right Amiga C the drag then clip the examples out of these docs to avoid typos.
  4.  
  5. A word of caution. NEVER try to read from both ends of the pipe at the same time. If you 'type awnpipe:mypipe1' in two separate shells both will hang waiting for data to come from the pipe.
  6.  
  7. If this happens to you during testing open the pipe a third time adding '/a' to the pipename 'type awnpipe:mypipe/a'. this causes the pending reads to abort and the deadlock (hang) ends.
  8.  
  9. ---
  10.  
  11. It is possible to tap into or duplicate the data passed in a pipe. '/t' will add a readonly third end to a pipe.
  12.  
  13. Make sure you have two different shells available.
  14.  
  15. In the first shell type 'type awnpipe:mypipe/t'
  16.  
  17. In the second shell type 'echo >awnpipe:mypipe hello'
  18. In the second shell type 'type >awnpipe:mypipe '
  19.  
  20.  The word hello came back from both the second end of the pipe and the 'Tap' third end.
  21.  
  22. ---
  23.  
  24. In the first shell type 'copy con:////pipe-test/close awnpipe:mypipe'
  25. In the second shell type 'type >awnpipe:mypipe '
  26.  
  27. Type a few lines of text into the test con:, not nothing comes out in the second shell. Close the test con:, now the data comes out. This is because the type command wants to read large blocks of data.
  28.  
  29. '/i' will cause data to pass out of the pipe immediately (as soon as its available).
  30.  
  31. In the first shell type 'copy con:////pipe-test/close awnpipe:mypipe'
  32. In the second shell type 'type >awnpipe:mypipe/i '
  33.  
  34. Now the text comes out of the pipe each time you hit return in the test con:.
  35. Close the test con: to end the example.
  36.  
  37. ---
  38.  
  39. You can use AWNPipe to read the tooltypes of an icon. The second end of the pipe automatically reads the tooltypes of FILENAME when '/xiFILENAME' is used. NOTE that parameters that start with '/x' can not be mixed with other parameters!
  40.  
  41. In a shell type 'type awnpipe:mypipe/xiDevs:dosdrivers/awnpipe'
  42.  
  43. YES the pipe name contains two colons ':', don't let it bug you.
  44.  
  45.  The tooltype information from Devs:dosdrivers/awnpipe prints out. Note you do not include '.info' in the file name.
  46.  
  47. ---
  48.  
  49.  AWNPipe can be used to test pattern matching of text. '/xm' is used for pattern matching. Data is usually written into the pipe, and the results of the pattern matching read back from THE SAME END OF THE PIPE. The second end of the pipe is automatically connected to a task that is doing the pattern matching. '/xmrFILENAME' causes the data to be read from a file rather than the pipe, the match results are read from the pipe.
  50.  
  51. In a shell type 'type awnpipe:mypipe/xmrcon:////pipetest/close'
  52.  
  53. In the pipetest con: type '#?.' . This sets a pattern to match to. 'ok 1' should come back from the pipe. ('ok 0' would means you did not enter a pattern so an exact match of the text will be tested for.)
  54.  
  55. In the pipetest con: enter some text. If the text ends with '.' then the pipe responds with '1' meaning a match. If not the pipe responds with '0' meaning no match. Close the pipe test con: to end the example.
  56.  
  57.